"""
文件名: AddressInterface.py
作用: 封装收货地址相关接口
作者: 健哥
"""

from Untils.SendMethod import SendMethod
from Interface.MemberInterface import MemberInterface


class AddressInterface:
    def __init__(self):
        self.url = 'http://139.159.146.104:8083'
        member = MemberInterface()
        self.headers = member.get_token(username='冰红茶', password='123456')

    def add_address(self, payload):
        """
        添加收货地址接口
        :param payload: 收货地址请求参数
        :return:
        """
        url = self.url + '/member/address/add'
        return SendMethod.send_method(method='post', url=url, json=payload, headers=self.headers)

    def get_address_list(self):
        """
        显示所有收货地址
        :return:
        """
        url = self.url + '/member/address/list'
        return SendMethod.send_method(method='get', url=url, headers=self.headers)


if __name__ == '__main__':
    address = AddressInterface()
    payload = {
        "city": "成都市",
        "defaultStatus": 0,
        "detailAddress": "天府新谷",
        "id": 0,
        "memberId": 121,
        "name": "冰红茶",
        "phoneNumber": "13812345678",
        "postCode": "123456",
        "province": "四川省",
        "region": "武侯区"
    }
    address.add_address(payload=payload)
    print(address.get_address_list())
